//
//  ViewController.swift
//  AlterationSwitch
//
//  Created by solarke_apple_mini_1 on 2018/10/22.
//  Copyright © 2018年 石家庄科林电气股份有限公司. All rights reserved.
//

import UIKit
import NetworkExtension
import SystemConfiguration.CaptiveNetwork

func getUsedSSID() -> String {
    let interfaces = CNCopySupportedInterfaces()
    var ssid = ""
    if interfaces != nil {
        let interfacesArray = CFBridgingRetain(interfaces) as! Array<AnyObject>
        if interfacesArray.count > 0 {
            let interfaceName = interfacesArray[0] as! CFString
            let ussafeInterfaceData = CNCopyCurrentNetworkInfo(interfaceName)
            if (ussafeInterfaceData != nil) {
                let interfaceData = ussafeInterfaceData as! Dictionary<String, Any>
                ssid = interfaceData["SSID"]! as! String
            }
        }
    }
    return ssid
}
